package com.parkingspace.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.parkingspace.dao.ParkingInformationMapper;
import com.parkingspace.entity.ParkingInformation;
import com.parkingspace.service.IParkingInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 车位信息表 服务实现类
 * </p>
 *
 * @author Gapper
 * @since 2021-05-24
 */
@Service
public class ParkingInformationServiceImpl extends ServiceImpl<ParkingInformationMapper, ParkingInformation> implements IParkingInformationService {

	@Resource
	private ParkingInformationMapper parkingInformationMapper;

	@Override
	public Boolean updateById(Long parkingId) throws Exception {
		if (parkingId == null) {
			throw new RuntimeException("非法参数!");
		}
		QueryWrapper<ParkingInformation> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("parking_id", parkingId);
		ParkingInformation parkingInformation = new ParkingInformation();
		parkingInformation.setLicensePlateNumberEntering(1);
		boolean b = parkingInformationMapper.update(parkingInformation,queryWrapper) == 1;
		if (!b) {
			throw new RuntimeException("录入车牌失败!");
		}
		return b;
	}
}
